import { useEffect,useState } from "react"
import { fetchChannelAPI, type ChannelItem } from '@/apis/list'
import './style.css'
function useTabs(){
  const [channels, setChannels] = useState<ChannelItem[]>([])
  useEffect(() => {
    async function getChannels() {
      try {
        const res = await fetchChannelAPI()
        setChannels(res.data.data.channels)
      } catch (error) {
        throw new Error('fetch channels error')
      }
    } getChannels()
  }, [])
  return {
    channels,//对象的写法
    
  }

}
export {useTabs}
//抽象出来useTabs逻辑代码